<template>
  <!-- vue实例外创建 -->
  <div>
    <el-container>
      <el-header>
        <h1>人员管理系统</h1>
        <div>
          <el-dropdown>
            <span class="el-dropdown-link">
              <img class="headimg"
                src="https://tse4-mm.cn.bing.net/th/id/OIP-C.hemwceVcDa64rHlHyxmIbgHaG2?w=202&h=187&c=7&r=0&o=5&dpr=1.5&pid=1.7"
                alt="">
            </span>
            <el-dropdown-menu slot="dropdown">
              <el-dropdown-item>个人中心</el-dropdown-item>
              <el-dropdown-item>控制台</el-dropdown-item>
              <el-dropdown-item divided>退出</el-dropdown-item>
            </el-dropdown-menu>
          </el-dropdown>
        </div>
      </el-header>
      <el-container>
        <el-aside width="200px">
          <el-menu default-active="2" class="el-menu-vertical-demo" @open="handleOpen" @close="handleClose"
            background-color="#545c64" text-color="#fff" active-text-color="#ffd04b" router>

            <el-submenu :index="item.path" v-for="item in muenuslist" :key="item.id">
              <template slot="title">
                <i class="el-icon-location"></i>
                <span>{{ item.authName }}</span>
              </template>
              <el-menu-item-group v-for="ited in item.children" :key="ited.id">
                <el-menu-item :index="ited.path"> {{ ited.authName }}</el-menu-item>
              </el-menu-item-group>
            </el-submenu>
          </el-menu>
        </el-aside>
        <el-main>
          <router-view></router-view>
        </el-main>
      </el-container>
    </el-container>
  </div>
</template>

<script>
import axios from 'axios';
import { GetMenus } from '@/api/user';
export default {
  data() {
    return {
      // 侧边栏数据
      muenuslist: []
    };
  },
  methods: {
    // 导航跳转
    goto2() {
      this.$router.push('goto2')
    },
    handleOpen(key, keyPath) {
      console.log(key, keyPath);
    },
    handleClose(key, keyPath) {
      console.log(key, keyPath);
    },

    //请求区
    // 获取侧边栏
    async getdata() {
      let { data } = await GetMenus()
      this.muenuslist = data
      console.log(this.muenuslist)
    }
  },
  mounted() {
    this.getdata()

  }
};
</script>

<style scoped>
.el-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.headimg {
  width: 40px;
  height: 40px;
  border-radius: 50%;
}

h1 {
  color: var(--fzcolor);
}

.el-header {
  background-color: var(--color);
}

.el-aside {
  background-color: var(--color);
  height: 92.9vh;
  overflow: hidden;
}

.el-main {
  background-color: #f3cf0a24;
}

.el-menu {
  overflow: hidden;
  border-right: 1px solid var(--color);
}
</style>
